<template>
	<view>
		<!-- 操作菜单 -->
		<uni-popup ref="popup" type="center">
			<view class="modal_warp col_conter">
				<view class="title">
					{{title}}
				</view>
				<view class="msg col_center">
					<view class="defult_msg">
						{{msg}}
					</view>
					<view class="sm_msg" v-if="smMsg != ''">
						{{smMsg}}
					</view>
				</view>
				<view class="btn_warp row_center">
					<view class="btn cancel" @click="cancel">
						取消
					</view>
					<view class="btn confirm" @click="confirm">
						{{confirmBtn}}
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "com-modal",
		props: {
			title: {
				type: String,
				default: '提示'
			},
			msg: {
				type: String,
				default: '确认吗？'
			},
			smMsg: {
				type: String,
				default: ''
			},
			confirmBtn: {
				type: String,
				default: '确定'
			}
		},
		data() {
			return {

			};
		},
		methods: {
			close() {
				this.$refs.popup.close()
			},
			open() {
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open()
			},
			confirm() {
				this.$emit('confirm')
			},
			cancel() {
				this.close();
				this.$emit('cancel')
			}
		}
	}
</script>

<style lang="scss">
	.modal_warp {
		width: 588rpx;
		height: 382rpx;
		background: #28243D;
		border-radius: 16rpx;
		font-family: PingFang SC;
		align-items: center;

		.title {
			margin-top: 66rpx;
			height: 30rpx;
			font-size: 32rpx;
			font-weight: 500;
			color: #F1EDFF;
		}
		
		.col_center {
			display: flex;
			flex-direction: column;
		}

		.msg {
			justify-content: center;
			align-items: center;
			width: 100%;
			height: 180rpx;
			font-size: 32rpx;
			font-weight: 500;
			color: #E5DDFF;
			opacity: 0.6;
			
			.sm_msg {
				margin-top: 14rpx;
				font-size: 24rpx;
				color: #E5DDFF;
			}
		}

		.btn_warp {
			width: 100%;
			height: 102rpx;

			.btn {
				width: 50%;
				height: 102rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 102rpx;
				text-align: center;

				&.cancel {
					position: relative;
					color: #F1EDFF;
				}

				&.cancel::after {
					position: absolute;
					right: 0;
					top: 0;
					content: '';
					height: 100%;
					width: 1px;
					background-color: #E5DDFF;
					opacity: 0.1;
				}

				&.confirm {
					color: #3DFFF2;
				}
			}
		}
	}
</style>
